-----------------------------------------------------------------------------
--
-- Module      :  Common
-- Copyright   :  (c) Lakshmi Narasimhan
-- License     :  GNU-GPL
--
-- Maintainer  :  <lakshminaras2002 at gmail dot com>
-- Stability   :  provisional
-- Portability :  portable
--
--
--
---------------------------------------------------------------------------------
module Common ( 
	evaluateAndSetResult)
	where

import ParseUtils
import GhCalcUtils
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Glade

--evaluateAndSetResult ::
evaluateAndSetResult formulaEntry resultEntry errorLabel = do
    formula_text  <- entryGetText formulaEntry
    postfix_formula <- (run expr formula_text)
    putStrLn (show postfix_formula)
    case postfix_formula of
             (Right pformula)-> entrySetText  resultEntry (evaluate_postfix pformula)
             (Left err ) -> do
                             entrySetText  resultEntry "0"
                             labelSetText  errorLabel err
                             
